package com.acwing.partition12;

import java.io.*;

/**
 * @author rkc
 * @date 2022/7/25 9:02
 */
public class AC1114棋盘问题 {

    private static final int N = 10;
    private static char[][] g = new char[N][N];
    private static boolean[] row = new boolean[N], col = new boolean[N];
    private static int n, m, ans = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        while (true) {
            String[] ss = reader.readLine().split(" ");
            n = Integer.parseInt(ss[0]);
            m = Integer.parseInt(ss[1]);
            if (n == -1 && m == -1) break;
            ans = 0;
            for (int i = 0; i < N; i++) row[i] = col[i] = false;
            for (int i = 0; i < n; i++) {
                String s = reader.readLine();
                for (int j = 0; j < n; j++) {
                    g[i][j] = s.charAt(j);
                }
            }
            dfs(0, 0, 0);
            writer.write(ans + "\n");
        }
        writer.flush();
    }

    private static void dfs(int u, int x, int y) {
        if (u == m) {
            ans++;
            return;
        }
        int j = y;
        for (int i = x; i < n; i++) {
            for (; j < n; j++) {
                if (g[i][j] == '.' || g[i][j] == '*' || !check(i, j)) continue;
                g[i][j] = '*';
                row[i] = col[j] = true;
                dfs(u + 1, i, j);
                g[i][j] = '#';
                row[i] = col[j] = false;
            }
            j = 0;
        }
    }

    private static boolean check(int x, int y) {
        return !row[x] && !col[y];
    }
}
